package com.casic.worklog.controller;

import com.casic.worklog.model.Employee;
import com.casic.worklog.model.LogTable;
import com.casic.worklog.service.EmployeeService;
import com.casic.worklog.service.LogTableService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;

@Controller
@RequestMapping("/view")

/**
 * @author 黄志
 * @date 2019-09-13 14:26
 * @param null
 * @return 
 * @throws 
 * 
*/
public class ViewController {
    @Resource
    private EmployeeService employeeService;
    @Resource
    private LogTableService logTableService;

    /**跳转员工管理界面*/
    @GetMapping("/userMessage")
    public String getAllUser() {
        return "manager";
    }
    /**管理员界面通信录*/
    @RequestMapping("/addressBook")
    public String addressBook(){
        return "addressBook";
    }

    /**新增页面跳转*/
    @RequestMapping("/addUser")
    public String addUser(){
        return "updateOrAddUser";
    }

    /**更新页面跳转*/
    @RequestMapping("/updateUser")
    public String updateUser(Short id,Model model){
        Employee employee = employeeService.findUserById(id);
        model.addAttribute("theOne",employee);
        return "updateOrAddUser";
    }

    /**签到界面*/
    @RequestMapping("/sign")
    public String worknote(){
        return "workNote";
    }

    /**我的日志信息界面*/
    @RequestMapping("/myWorkNote")
    public String myWorkNote(){
        return "myWorkNote";
    }

    /**全部日志信息界面*/
    @RequestMapping("/allWorkNote")
    public String allWorkNote(){
        return "allWorkNote";
    }

    /**写日志*/
    @RequestMapping("/writeLog")
    public String writeLog(){
        return "updateOrAddLog";
    }

    /**更新日志*/
    @RequestMapping("/updateLog")
    public String updateLog(Short logId, Model model){
        LogTable logTable  = logTableService.findByLogId(logId);
        model.addAttribute("logMessage",logTable);
        return "updateOrAddLog";
    }
    /**携带id的日志跳转，查看日志界面*/
    @RequestMapping("/showLog")
    public String showLog(Short id,Model model){
        model.addAttribute("id",id);
        return "showLog";
    }

}
